Add OpenTelemetry histogram metrics for LLM operations in aliyun_trace#1
Draft
Copilot wants to merge 5 commits intorelease/e-1.8.1from
Draft
Add OpenTelemetry histogram metrics for LLM operations in aliyun_trace#1Copilot wants to merge 5 commits intorelease/e-1.8.1from
Copilot wants to merge 5 commits intorelease/e-1.8.1from
Conversation
Co-authored-by: c3013 <246969133+c3013@users.noreply.github.com>
Co-authored-by: c3013 <246969133+c3013@users.noreply.github.com>
Co-authored-by: c3013 <246969133+c3013@users.noreply.github.com>
Co-authored-by: c3013 <246969133+c3013@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add histogram metrics for gen_ai client and usage in aliyun_trace
Add OpenTelemetry histogram metrics for LLM operations in aliyun_trace
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements 7 histogram metrics for LLM operations in the aliyun_trace component, exported via OTLP to Aliyun endpoint. All metrics include
app_nametag.Metrics Added:
gen_ai.client.time_to_first_token- First token latencygen_ai.client.time_per_output_token- Per-token generation time (auto-calculated from duration/completion_tokens)gen_ai.client.time_between_token- Inter-token timinggen_ai.client.operation- Operation countgen_ai.usage.usage.prompt_tokens_details.cached_tokens- Cached token usagegen_ai.client.operation.duration- Total operation latencygen_ai.client.token.usage- Total token consumptionImplementation:
traceclient.py): OpenTelemetry SDK wrapper with histogram instruments, periodic export (5s), and graceful shutdownaliyun_trace.py): Metrics recorded automatically inbuild_workflow_llm_span()andmessage_trace()when LLM spans are createdtest_metrics_client.py): Unit tests covering initialization, recording, auto-calculation, and app_name tag validationMetrics are recorded transparently when LLM operations execute in workflows or message-based apps. No configuration changes required beyond existing aliyun_trace setup.
Screenshots
N/A - Backend metrics implementation
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint godsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.